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 "AliMUONCalibParam1I.h"
54 #include "AliMUONObjectPair.h"
55 #include "AliMUONV2DStore.h"
56 #include "AliMUONVCalibParam.h"
57 #include "AliMUONVDataIterator.h"
58 #include "AliMpArea.h"
59 #include "AliMpConstants.h"
60 #include "AliMpDEManager.h"
62 #include "AliMpSegmentation.h"
63 #include "AliMpStationType.h"
64 #include "AliMpVPadIterator.h"
65 #include "AliMpVSegmentation.h"
66 #include "Riostream.h"
68 #include "TObjArray.h"
69 #include "TStopwatch.h"
74 ClassImp(AliMUONPadStatusMapMaker)
76 Int_t AliMUONPadStatusMapMaker::fgkSelfDead = 1;
80 Bool_t IsZero(Double_t x)
82 return TMath::Abs(x) < AliMpConstants::LengthTolerance();
86 //_____________________________________________________________________________
87 AliMUONPadStatusMapMaker::AliMUONPadStatusMapMaker()
92 fTimerComputeStatusMap(0x0)
97 //_____________________________________________________________________________
98 AliMUONPadStatusMapMaker::~AliMUONPadStatusMapMaker()
101 delete fTimerComputeStatusMap;
104 //_____________________________________________________________________________
106 AliMUONPadStatusMapMaker::ComputeStatusMap(const TObjArray& neighbours,
107 Int_t detElemId) const
109 /// Given a list of neighbours of one pad (which includes the pad itself)
110 /// compute the status map (aka deadmap) for that pad.
112 fTimerComputeStatusMap->Start(kFALSE);
116 //Compute the statusmap related to the status of neighbouring
117 //pads. An invalid pad means "outside of edges".
119 TIter next(&neighbours);
122 while ( ( p = static_cast<AliMpPad*>(next()) ) )
131 status = GetPadStatus(detElemId,*p);
133 if ( ( fMask==0 && status !=0 ) || ( (status & fMask) != 0 ) )
140 fTimerComputeStatusMap->Stop();
144 //_____________________________________________________________________________
146 AliMUONPadStatusMapMaker::GetPadStatus(Int_t detElemId,
147 const AliMpPad& pad) const
149 /// Get the pad status
150 Int_t manuId = pad.GetLocation().GetFirst();
151 Int_t manuChannel = pad.GetLocation().GetSecond();
152 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->Get(detElemId,manuId));
153 return param->ValueAsInt(manuChannel);
156 //_____________________________________________________________________________
158 AliMUONPadStatusMapMaker::IsValid(const AliMpPad& pad,
159 const TVector2& shift) const
161 /// Whether pad.Position()+shift is within the detector
162 TVector2 testPos = pad.Position() - pad.Dimensions() + shift;
163 AliMpPad p = fSegmentation->PadByPosition(testPos,kFALSE);
167 //_____________________________________________________________________________
169 AliMUONPadStatusMapMaker::MakePadStatusMap(const AliMUONV2DStore& status,
172 /// Given the status store for all pads, compute a status map store
174 /// @param mask is the status mask to be tested to tell if a pad is ok or not
179 AliMpExMap chamberTimers(kTRUE);
180 fTimerComputeStatusMap = new TStopwatch;
181 fTimerComputeStatusMap->Start(kTRUE);
182 fTimerComputeStatusMap->Stop();
188 AliMUONV2DStore* statusMap = status.CloneEmpty();
190 AliMUONVDataIterator* it = status.Iterator();
191 AliMUONObjectPair* pair;
193 while ( ( pair = static_cast<AliMUONObjectPair*>(it->Next()) ) )
195 AliMpIntPair* ip = static_cast<AliMpIntPair*>(pair->First());
197 Int_t detElemId = ip->GetFirst();
199 Int_t manuId = ip->GetSecond();
200 Int_t chamber = AliMpDEManager::GetChamberId(detElemId);
202 TStopwatch* chTimer = static_cast<TStopwatch*>(chamberTimers.GetValue(chamber));
205 chTimer = new TStopwatch;
206 chTimer->Start(kTRUE);
208 chamberTimers.Add(chamber,chTimer);
211 chTimer->Start(kFALSE);
213 const AliMpVSegmentation* seg =
214 AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId);
217 AliMUONVCalibParam* statusEntry = static_cast<AliMUONVCalibParam*>(pair->Second());
219 AliMUONVCalibParam* statusMapEntry = static_cast<AliMUONVCalibParam*>
220 (statusMap->Get(detElemId,manuId));
224 statusMapEntry = new AliMUONCalibParam1I(64,0);
225 statusMap->Set(detElemId,manuId,statusMapEntry,false);
228 for ( Int_t manuChannel = 0; manuChannel < statusEntry->Size(); ++manuChannel )
230 // Loop over channels and for each channel loop on its immediate neighbours
231 // to produce a statusMap word for this channel.
233 AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE);
235 Int_t statusMapValue(0);
239 TObjArray neighbours;
240 neighbours.SetOwner(kTRUE);
241 Int_t n = fSegmentation->GetNeighbours(pad,neighbours,true,true);
242 statusMapValue = ComputeStatusMap(neighbours,detElemId);
246 statusMapValue = fgkSelfDead;
248 statusMapEntry->SetValueAsInt(manuChannel,0,statusMapValue);
255 TExMapIter cit = chamberTimers.GetIterator();
259 while ( cit.Next(key,value) )
261 TStopwatch* t = reinterpret_cast<TStopwatch*>(value);
262 cout << Form("Chamber %2ld CPU time/manu %5.0f ms ",key,t->CpuTime()*1e3/t->Counter());
266 cout << "ComputeStatusMap timer : ";
267 fTimerComputeStatusMap->Print();
270 cout << "MakePadStatusMap total timer : ";