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"
63 #include "AliMpSegmentation.h"
64 #include "AliMpStationType.h"
65 #include "AliMpVPadIterator.h"
66 #include "AliMpVSegmentation.h"
67 #include <Riostream.h>
69 #include <TObjArray.h>
70 #include <TStopwatch.h>
75 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 /// Make an empty (but complete) statusMap
175 AliMUONCalibParam1I param(64,0);
177 return AliMUON2DMap::Generate(param);
180 //_____________________________________________________________________________
182 AliMUONPadStatusMapMaker::MakePadStatusMap(const AliMUONV2DStore& status,
185 /// Given the status store for all pads, compute a status map store
188 /// \param mask is the status mask to be tested to tell if a pad is ok or not
193 AliMpExMap chamberTimers(kTRUE);
194 fTimerComputeStatusMap = new TStopwatch;
195 fTimerComputeStatusMap->Start(kTRUE);
196 fTimerComputeStatusMap->Stop();
202 AliMUONV2DStore* statusMap = status.CloneEmpty();
204 AliMUONVDataIterator* it = status.Iterator();
205 AliMUONObjectPair* pair;
207 while ( ( pair = static_cast<AliMUONObjectPair*>(it->Next()) ) )
209 AliMpIntPair* ip = static_cast<AliMpIntPair*>(pair->First());
211 Int_t detElemId = ip->GetFirst();
213 Int_t manuId = ip->GetSecond();
214 Int_t chamber = AliMpDEManager::GetChamberId(detElemId);
216 TStopwatch* chTimer = static_cast<TStopwatch*>(chamberTimers.GetValue(chamber));
219 chTimer = new TStopwatch;
220 chTimer->Start(kTRUE);
222 chamberTimers.Add(chamber,chTimer);
225 chTimer->Start(kFALSE);
227 const AliMpVSegmentation* seg =
228 AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId);
231 AliMUONVCalibParam* statusEntry = static_cast<AliMUONVCalibParam*>(pair->Second());
233 AliMUONVCalibParam* statusMapEntry = static_cast<AliMUONVCalibParam*>
234 (statusMap->Get(detElemId,manuId));
238 statusMapEntry = new AliMUONCalibParam1I(64,0);
239 statusMap->Set(detElemId,manuId,statusMapEntry,false);
242 for ( Int_t manuChannel = 0; manuChannel < statusEntry->Size(); ++manuChannel )
244 // Loop over channels and for each channel loop on its immediate neighbours
245 // to produce a statusMap word for this channel.
247 AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE);
249 Int_t statusMapValue(0);
253 TObjArray neighbours;
254 neighbours.SetOwner(kTRUE);
255 fSegmentation->GetNeighbours(pad,neighbours,true,true);
256 statusMapValue = ComputeStatusMap(neighbours,detElemId);
260 statusMapValue = fgkSelfDead;
262 statusMapEntry->SetValueAsInt(manuChannel,0,statusMapValue);
269 TExMapIter cit = chamberTimers.GetIterator();
273 while ( cit.Next(key,value) )
275 TStopwatch* t = reinterpret_cast<TStopwatch*>(value);
276 cout << Form("Chamber %2ld CPU time/manu %5.0f ms ",key,t->CpuTime()*1e3/t->Counter());
280 cout << "ComputeStatusMap timer : ";
281 fTimerComputeStatusMap->Print();
284 cout << "MakePadStatusMap total timer : ";