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 "AliMUONCalibParam1I.h"
55 #include "AliMUONObjectPair.h"
56 #include "AliMUONV2DStore.h"
57 #include "AliMUONVCalibParam.h"
58 #include "AliMUONVDataIterator.h"
59 #include "AliMpArea.h"
60 #include "AliMpConstants.h"
61 #include "AliMpDEManager.h"
62 #include "AliMpManuList.h"
64 #include "AliMpSegmentation.h"
65 #include "AliMpStationType.h"
66 #include "AliMpVPadIterator.h"
67 #include "AliMpVSegmentation.h"
68 #include <Riostream.h>
70 #include <TObjArray.h>
71 #include <TStopwatch.h>
76 ClassImp(AliMUONPadStatusMapMaker)
78 Int_t AliMUONPadStatusMapMaker::fgkSelfDead = 1;
82 Bool_t IsZero(Double_t x)
84 return TMath::Abs(x) < AliMpConstants::LengthTolerance();
88 //_____________________________________________________________________________
89 AliMUONPadStatusMapMaker::AliMUONPadStatusMapMaker()
94 fTimerComputeStatusMap(0x0)
99 //_____________________________________________________________________________
100 AliMUONPadStatusMapMaker::~AliMUONPadStatusMapMaker()
103 delete fTimerComputeStatusMap;
106 //_____________________________________________________________________________
108 AliMUONPadStatusMapMaker::ComputeStatusMap(const TObjArray& neighbours,
109 Int_t detElemId) const
111 /// Given a list of neighbours of one pad (which includes the pad itself)
112 /// compute the status map (aka deadmap) for that pad.
114 fTimerComputeStatusMap->Start(kFALSE);
118 //Compute the statusmap related to the status of neighbouring
119 //pads. An invalid pad means "outside of edges".
121 TIter next(&neighbours);
124 while ( ( p = static_cast<AliMpPad*>(next()) ) )
133 status = GetPadStatus(detElemId,*p);
135 if ( ( fMask==0 && status !=0 ) || ( (status & fMask) != 0 ) )
142 fTimerComputeStatusMap->Stop();
146 //_____________________________________________________________________________
148 AliMUONPadStatusMapMaker::GetPadStatus(Int_t detElemId,
149 const AliMpPad& pad) const
151 /// Get the pad status
152 Int_t manuId = pad.GetLocation().GetFirst();
153 Int_t manuChannel = pad.GetLocation().GetSecond();
154 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->Get(detElemId,manuId));
155 return param->ValueAsInt(manuChannel);
158 //_____________________________________________________________________________
160 AliMUONPadStatusMapMaker::IsValid(const AliMpPad& pad,
161 const TVector2& shift) const
163 /// Whether pad.Position()+shift is within the detector
164 TVector2 testPos = pad.Position() - pad.Dimensions() + shift;
165 AliMpPad p = fSegmentation->PadByPosition(testPos,kFALSE);
169 //_____________________________________________________________________________
171 AliMUONPadStatusMapMaker::MakeEmptyPadStatusMap()
173 AliMUONV2DStore* padStatusMap = new AliMUON2DMap(kTRUE);
175 TList* list = AliMpManuList::ManuList();
181 while ( ( pair = static_cast<AliMpIntPair*>(next()) ) )
183 Int_t detElemId = pair->GetFirst();
184 Int_t manuId = pair->GetSecond();
185 padStatusMap->Set(detElemId,manuId,new AliMUONCalibParam1I(64,0),kFALSE);
193 //_____________________________________________________________________________
195 AliMUONPadStatusMapMaker::MakePadStatusMap(const AliMUONV2DStore& status,
198 /// Given the status store for all pads, compute a status map store
200 /// @param mask is the status mask to be tested to tell if a pad is ok or not
205 AliMpExMap chamberTimers(kTRUE);
206 fTimerComputeStatusMap = new TStopwatch;
207 fTimerComputeStatusMap->Start(kTRUE);
208 fTimerComputeStatusMap->Stop();
214 AliMUONV2DStore* statusMap = status.CloneEmpty();
216 AliMUONVDataIterator* it = status.Iterator();
217 AliMUONObjectPair* pair;
219 while ( ( pair = static_cast<AliMUONObjectPair*>(it->Next()) ) )
221 AliMpIntPair* ip = static_cast<AliMpIntPair*>(pair->First());
223 Int_t detElemId = ip->GetFirst();
225 Int_t manuId = ip->GetSecond();
226 Int_t chamber = AliMpDEManager::GetChamberId(detElemId);
228 TStopwatch* chTimer = static_cast<TStopwatch*>(chamberTimers.GetValue(chamber));
231 chTimer = new TStopwatch;
232 chTimer->Start(kTRUE);
234 chamberTimers.Add(chamber,chTimer);
237 chTimer->Start(kFALSE);
239 const AliMpVSegmentation* seg =
240 AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId);
243 AliMUONVCalibParam* statusEntry = static_cast<AliMUONVCalibParam*>(pair->Second());
245 AliMUONVCalibParam* statusMapEntry = static_cast<AliMUONVCalibParam*>
246 (statusMap->Get(detElemId,manuId));
250 statusMapEntry = new AliMUONCalibParam1I(64,0);
251 statusMap->Set(detElemId,manuId,statusMapEntry,false);
254 for ( Int_t manuChannel = 0; manuChannel < statusEntry->Size(); ++manuChannel )
256 // Loop over channels and for each channel loop on its immediate neighbours
257 // to produce a statusMap word for this channel.
259 AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE);
261 Int_t statusMapValue(0);
265 TObjArray neighbours;
266 neighbours.SetOwner(kTRUE);
267 fSegmentation->GetNeighbours(pad,neighbours,true,true);
268 statusMapValue = ComputeStatusMap(neighbours,detElemId);
272 statusMapValue = fgkSelfDead;
274 statusMapEntry->SetValueAsInt(manuChannel,0,statusMapValue);
281 TExMapIter cit = chamberTimers.GetIterator();
285 while ( cit.Next(key,value) )
287 TStopwatch* t = reinterpret_cast<TStopwatch*>(value);
288 cout << Form("Chamber %2ld CPU time/manu %5.0f ms ",key,t->CpuTime()*1e3/t->Counter());
292 cout << "ComputeStatusMap timer : ";
293 fTimerComputeStatusMap->Print();
296 cout << "MakePadStatusMap total timer : ";