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 "AliMUONVStore.h"
57 #include "AliMUONVCalibParam.h"
58 #include "AliMpConstants.h"
59 #include "AliMpIntPair.h"
60 #include "AliMpManuList.h"
61 #include <Riostream.h>
63 #include <TStopwatch.h>
66 ClassImp(AliMUONPadStatusMapMaker)
69 Int_t AliMUONPadStatusMapMaker::fgkSelfDead = 1;
71 //_____________________________________________________________________________
72 AliMUONPadStatusMapMaker::AliMUONPadStatusMapMaker(const AliMUONCalibrationData& calibData)
76 fCalibrationData(calibData)
81 //_____________________________________________________________________________
82 AliMUONPadStatusMapMaker::~AliMUONPadStatusMapMaker()
87 //_____________________________________________________________________________
89 AliMUONPadStatusMapMaker::ComputeStatusMap(const AliMUONVCalibParam& neighbours,
91 Int_t detElemId) const
93 /// Given a list of neighbours of one pad (which includes the pad itself)
94 /// compute the status map (aka deadmap) for that pad.
98 //Compute the statusmap related to the status of neighbouring
99 //pads. An invalid pad means "outside of edges".
101 Int_t n = neighbours.Dimension();
102 for ( Int_t i = 0; i < n; ++i )
104 Int_t x = neighbours.ValueAsInt(manuChannel,i);
106 neighbours.UnpackValue(x,m,c);
107 if ( c < 0 ) continue;
115 status = GetPadStatus(detElemId,m,c);
117 if ( ( fMask==0 && status !=0 ) || ( (status & fMask) != 0 ) )
125 //_____________________________________________________________________________
127 AliMUONPadStatusMapMaker::GetPadStatus(Int_t detElemId,
128 Int_t manuId, Int_t manuChannel) const
131 /// Get the pad status
132 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->FindObject(detElemId,manuId));
133 return param->ValueAsInt(manuChannel);
136 //_____________________________________________________________________________
138 AliMUONPadStatusMapMaker::MakeEmptyPadStatusMap()
140 /// Make an empty (but complete) statusMap
142 AliMUONVStore* store = new AliMUON2DMap(true);
144 TList* list = AliMpManuList::ManuList();
150 while ( ( pair = static_cast<AliMpIntPair*>(next()) ) )
152 Int_t detElemId = pair->GetFirst();
153 Int_t manuId = pair->GetSecond();
154 AliMUONVCalibParam* param = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),
165 //_____________________________________________________________________________
167 AliMUONPadStatusMapMaker::MakePadStatusMap(const AliMUONVStore& status,
170 /// Given the status store for all pads, compute a status map store
173 /// \param mask is the status mask to be tested to tell if a pad is ok or not
181 AliMUONVStore* neighbourStore = fCalibrationData.Neighbours();
183 AliMUONVStore* statusMap = status.Create();
185 TIter next(status.CreateIterator());
186 AliMUONVCalibParam* statusEntry;
188 while ( ( statusEntry = static_cast<AliMUONVCalibParam*>(next()) ) )
190 Int_t detElemId = statusEntry->ID0();
191 Int_t manuId = statusEntry->ID1();
193 AliMUONVCalibParam* statusMapEntry = static_cast<AliMUONVCalibParam*>
194 (statusMap->FindObject(detElemId,manuId));
198 statusMapEntry = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),
200 statusMap->Add(statusMapEntry);
203 AliMUONVCalibParam* neighbours = static_cast<AliMUONVCalibParam*>
204 (neighbourStore->FindObject(detElemId,manuId));
208 AliFatal(Form("Could not find neighbours for DE %d manuId %d",
213 for ( Int_t manuChannel = 0; manuChannel < statusEntry->Size(); ++manuChannel )
215 // Loop over channels and for each channel loop on its immediate neighbours
216 // to produce a statusMap word for this channel.
218 Int_t statusMapValue(0);
220 Int_t x = neighbours->ValueAsInt(manuChannel,0);
224 // channel is a valid one (i.e. (manuId,manuChannel) is an existing pad)
225 statusMapValue = ComputeStatusMap(*neighbours,manuChannel,detElemId);
229 statusMapValue = fgkSelfDead;
232 statusMapEntry->SetValueAsInt(manuChannel,0,statusMapValue);
238 cout << "MakePadStatusMap total timer : ";