1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 /// \class AliMUONPadStatusMapMaker
19 /// Convert a pad status container into a pad status *map* container
21 /// A pad status is one 32-bits word describing whether this pad pedestal, gains
22 /// hv is correct or not.
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
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)
42 /// so some care must be taken when designing a mask to be tested ;-) if you
43 /// want to go farther than immediate neighbours...
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).
48 /// \author Laurent Aphecetche
50 #include "AliMUONPadStatusMapMaker.h"
53 #include "AliMUON2DMap.h"
54 #include "AliMUONCalibParamNI.h"
55 #include "AliMUONCalibrationData.h"
56 #include "AliMUONObjectPair.h"
57 #include "AliMUONV2DStore.h"
58 #include "AliMUONVCalibParam.h"
59 #include "AliMUONVDataIterator.h"
60 #include "AliMpIntPair.h"
61 #include <Riostream.h>
62 #include <TStopwatch.h>
65 ClassImp(AliMUONPadStatusMapMaker)
68 Int_t AliMUONPadStatusMapMaker::fgkSelfDead = 1;
70 //_____________________________________________________________________________
71 AliMUONPadStatusMapMaker::AliMUONPadStatusMapMaker(const AliMUONCalibrationData& calibData)
75 fCalibrationData(calibData)
80 //_____________________________________________________________________________
81 AliMUONPadStatusMapMaker::~AliMUONPadStatusMapMaker()
86 //_____________________________________________________________________________
88 AliMUONPadStatusMapMaker::ComputeStatusMap(const AliMUONVCalibParam& neighbours,
90 Int_t detElemId) const
92 /// Given a list of neighbours of one pad (which includes the pad itself)
93 /// compute the status map (aka deadmap) for that pad.
97 //Compute the statusmap related to the status of neighbouring
98 //pads. An invalid pad means "outside of edges".
100 Int_t n = neighbours.Dimension();
101 for ( Int_t i = 0; i < n; ++i )
103 Int_t x = neighbours.ValueAsInt(manuChannel,i);
105 neighbours.UnpackValue(x,m,c);
106 if ( c < 0 ) continue;
114 status = GetPadStatus(detElemId,m,c);
116 if ( ( fMask==0 && status !=0 ) || ( (status & fMask) != 0 ) )
124 //_____________________________________________________________________________
126 AliMUONPadStatusMapMaker::GetPadStatus(Int_t detElemId,
127 Int_t manuId, Int_t manuChannel) const
130 /// Get the pad status
131 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->Get(detElemId,manuId));
132 return param->ValueAsInt(manuChannel);
135 //_____________________________________________________________________________
137 AliMUONPadStatusMapMaker::MakeEmptyPadStatusMap()
139 /// Make an empty (but complete) statusMap
141 AliMUONCalibParamNI param(1,64,0);
143 return AliMUON2DMap::Generate(param);
146 //_____________________________________________________________________________
148 AliMUONPadStatusMapMaker::MakePadStatusMap(const AliMUONV2DStore& status,
151 /// Given the status store for all pads, compute a status map store
154 /// \param mask is the status mask to be tested to tell if a pad is ok or not
162 AliMUONV2DStore* neighbourStore = fCalibrationData.Neighbours();
164 AliMUONV2DStore* statusMap = status.CloneEmpty();
166 AliMUONVDataIterator* it = status.Iterator();
167 AliMUONObjectPair* pair;
169 while ( ( pair = static_cast<AliMUONObjectPair*>(it->Next()) ) )
171 AliMpIntPair* ip = static_cast<AliMpIntPair*>(pair->First());
173 Int_t detElemId = ip->GetFirst();
174 Int_t manuId = ip->GetSecond();
176 AliMUONVCalibParam* statusEntry = static_cast<AliMUONVCalibParam*>(pair->Second());
178 AliMUONVCalibParam* statusMapEntry = static_cast<AliMUONVCalibParam*>
179 (statusMap->Get(detElemId,manuId));
183 statusMapEntry = new AliMUONCalibParamNI(1,64,0);
184 statusMap->Set(detElemId,manuId,statusMapEntry,false);
187 AliMUONVCalibParam* neighbours = static_cast<AliMUONVCalibParam*>
188 (neighbourStore->Get(detElemId,manuId));
192 AliFatal(Form("Could not find neighbours for DE %d manuId %d",
197 for ( Int_t manuChannel = 0; manuChannel < statusEntry->Size(); ++manuChannel )
199 // Loop over channels and for each channel loop on its immediate neighbours
200 // to produce a statusMap word for this channel.
202 Int_t statusMapValue(0);
204 Int_t x = neighbours->ValueAsInt(manuChannel,0);
207 { // channel is a valid one (i.e. (manuId,manuChannel) is an existing pad)
209 statusMapValue = ComputeStatusMap(*neighbours,manuChannel,detElemId);
213 statusMapValue = fgkSelfDead;
216 statusMapEntry->SetValueAsInt(manuChannel,0,statusMapValue);
219 if (it->IsOwner()) delete pair;
227 cout << "MakePadStatusMap total timer : ";