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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONPadStatusMapMaker
21 /// Convert a pad status container into a pad status *map* container
23 /// A pad status is one 32-bits word describing whether this pad pedestal, gains
24 /// hv is correct or not.
26 /// A pad status *map* is one 32-bits (of which 24 only are used)
27 /// word describing whether this pad neighbours are ok or not
28 /// (whether a pad is ok or not is determined by applying a given
29 /// bitmask to the pad status word). Each bit in this word is related to one
30 /// neighbour, assuming the pad itself is at bit 0
40 /// Note that for instance in NonBending plane of slats, at the boundaries
41 /// between two pad densities, the pictures is a bit different, e.g.
42 /// (bits in () are always zero)
44 /// so some care must be taken when designing a mask to be tested ;-) if you
45 /// want to go farther than immediate neighbours...
47 /// If a pad is at a physical boundary, is will for sure have some bits at 1
48 /// (i.e. a non-existing neighbour is considered = bad).
50 /// \author Laurent Aphecetche
51 //-----------------------------------------------------------------------------
53 #include "AliMUONPadStatusMapMaker.h"
56 #include "AliMUON2DMap.h"
57 #include "AliMUONCalibParamNI.h"
58 #include "AliMUONCalibrationData.h"
59 #include "AliMUONVStore.h"
60 #include "AliMUONVCalibParam.h"
61 #include "AliMpConstants.h"
62 #include "AliMpIntPair.h"
63 #include "AliMpManuList.h"
64 #include <Riostream.h>
66 #include <TStopwatch.h>
69 ClassImp(AliMUONPadStatusMapMaker)
72 Int_t AliMUONPadStatusMapMaker::fgkSelfDead = 1;
74 //_____________________________________________________________________________
75 AliMUONPadStatusMapMaker::AliMUONPadStatusMapMaker(const AliMUONCalibrationData& calibData)
79 fCalibrationData(calibData)
84 //_____________________________________________________________________________
85 AliMUONPadStatusMapMaker::~AliMUONPadStatusMapMaker()
90 //_____________________________________________________________________________
92 AliMUONPadStatusMapMaker::ComputeStatusMap(const AliMUONVCalibParam& neighbours,
94 Int_t detElemId) const
96 /// Given a list of neighbours of one pad (which includes the pad itself)
97 /// compute the status map (aka deadmap) for that pad.
101 //Compute the statusmap related to the status of neighbouring
102 //pads. An invalid pad means "outside of edges".
104 Int_t n = neighbours.Dimension();
105 for ( Int_t i = 0; i < n; ++i )
107 Int_t x = neighbours.ValueAsInt(manuChannel,i);
109 neighbours.UnpackValue(x,m,c);
110 if ( c < 0 ) continue;
118 status = GetPadStatus(detElemId,m,c);
120 if ( ( fMask==0 && status !=0 ) || ( (status & fMask) != 0 ) )
128 //_____________________________________________________________________________
130 AliMUONPadStatusMapMaker::GetPadStatus(Int_t detElemId,
131 Int_t manuId, Int_t manuChannel) const
134 /// Get the pad status
135 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->FindObject(detElemId,manuId));
136 return param->ValueAsInt(manuChannel);
139 //_____________________________________________________________________________
141 AliMUONPadStatusMapMaker::MakeEmptyPadStatusMap()
143 /// Make an empty (but complete) statusMap
145 AliMUONVStore* store = new AliMUON2DMap(true);
147 TList* list = AliMpManuList::ManuList();
153 while ( ( pair = static_cast<AliMpIntPair*>(next()) ) )
155 Int_t detElemId = pair->GetFirst();
156 Int_t manuId = pair->GetSecond();
157 AliMUONVCalibParam* param = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),
168 //_____________________________________________________________________________
170 AliMUONPadStatusMapMaker::MakePadStatusMap(const AliMUONVStore& status,
173 /// Given the status store for all pads, compute a status map store
176 /// \param mask is the status mask to be tested to tell if a pad is ok or not
184 AliMUONVStore* neighbourStore = fCalibrationData.Neighbours();
186 AliMUONVStore* statusMap = status.Create();
188 TIter next(status.CreateIterator());
189 AliMUONVCalibParam* statusEntry;
191 while ( ( statusEntry = static_cast<AliMUONVCalibParam*>(next()) ) )
193 Int_t detElemId = statusEntry->ID0();
194 Int_t manuId = statusEntry->ID1();
196 AliMUONVCalibParam* statusMapEntry = static_cast<AliMUONVCalibParam*>
197 (statusMap->FindObject(detElemId,manuId));
201 statusMapEntry = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),
203 statusMap->Add(statusMapEntry);
206 AliMUONVCalibParam* neighbours = static_cast<AliMUONVCalibParam*>
207 (neighbourStore->FindObject(detElemId,manuId));
211 AliFatal(Form("Could not find neighbours for DE %d manuId %d",
216 for ( Int_t manuChannel = 0; manuChannel < statusEntry->Size(); ++manuChannel )
218 // Loop over channels and for each channel loop on its immediate neighbours
219 // to produce a statusMap word for this channel.
221 Int_t statusMapValue(0);
223 Int_t x = neighbours->ValueAsInt(manuChannel,0);
227 // channel is a valid one (i.e. (manuId,manuChannel) is an existing pad)
228 statusMapValue = ComputeStatusMap(*neighbours,manuChannel,detElemId);
232 statusMapValue = fgkSelfDead;
235 statusMapEntry->SetValueAsInt(manuChannel,0,statusMapValue);
241 cout << "MakePadStatusMap total timer : ";