Leftover from previous commit
[u/mrichter/AliRoot.git] / MUON / MUONStatusMap.C
CommitLineData
d565d56c 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17
e54bf126 18/// \ingroup macros
19/// \file MUONStatusMap.C
20/// \brief Macro to check/test pad status and pad status map makers
3fb89a07 21///
e54bf126 22/// \author Laurent Aphecetche
d565d56c 23
24#if !defined(__CINT__) || defined(__MAKECINT__)
25#include "AliCDBManager.h"
26#include "AliMUONCalibrationData.h"
d565d56c 27#include "AliMUONPadStatusMaker.h"
28#include "AliMUONPadStatusMapMaker.h"
d565d56c 29#include "AliMUONVCalibParam.h"
7190ece1 30#include "AliMUONVStore.h"
31#include "AliMpCDB.h"
32#include "AliMpConstants.h"
33#include "AliMpDDLStore.h"
34#include "AliMpDetElement.h"
7190ece1 35#include "AliMpManuIterator.h"
d565d56c 36#include "Riostream.h"
37#endif
38
7190ece1 39void FindBad(AliMUONPadStatusMaker& statusMaker, Int_t mask, Int_t& nBadPads, Int_t& nPads)
d565d56c 40{
7190ece1 41 AliMpManuIterator it;
42
43 nBadPads = nPads = 0;
d565d56c 44
7190ece1 45 Int_t detElemId;
46 Int_t manuId;
47
48 while ( it.Next(detElemId,manuId) )
d565d56c 49 {
d565d56c 50 Bool_t bad(kFALSE);
7190ece1 51
52 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
53
54 Int_t nb(0);
55 Int_t n(0);
56
57 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
d565d56c 58 {
7190ece1 59 if ( de->IsConnectedChannel(manuId,i) )
60 {
61 ++n;
62 ++nPads;
63 Int_t status = statusMaker.PadStatus(detElemId,manuId,i);
64 if ( ( status & mask) || (!mask && status) )
65 {
66 bad = kTRUE;
67 ++nBadPads;
68 ++nb;
69 }
70 }
d565d56c 71 }
7190ece1 72
d565d56c 73 if (bad)
74 {
7190ece1 75 cout << Form("DE %4d ManuId %4d %2d bad pads over %2d pads",
76 detElemId,manuId,nb,n) << endl;
d565d56c 77 }
78 }
79}
80
162637e4 81AliMUONVStore* MUONStatusMap(const TString& cdbStorage = "local://$ALICE_ROOT/OCDB",
7190ece1 82 Int_t runNumber=0, Bool_t statusOnly=kFALSE,
83 Int_t mask=0x8080)
3fb89a07 84{
85 AliCDBManager::Instance()->SetDefaultStorage(cdbStorage.Data());
7190ece1 86 AliCDBManager::Instance()->SetRun(runNumber);
3fb89a07 87
7190ece1 88 AliMpCDB::LoadDDLStore();
89
d565d56c 90 AliMUONCalibrationData cd(runNumber);
91
92 AliMUONPadStatusMaker statusMaker(cd);
93
94// statusMaker.SetPedMeanLimits(50,200);
7190ece1 95// statusMaker.SetPedSigmaLimits(0.5,2);
d565d56c 96
7190ece1 97 Int_t nbad;
98 Int_t ntotal;
99
100 FindBad(statusMaker,mask,nbad,ntotal);
101
102 if (ntotal<=0)
d565d56c 103 {
7190ece1 104 cout << "Error : got no pad at all ?!" << endl;
105 return 0x0;
106 }
107
108 cout << Form("Nbad = %6d over %6d pads (%7.2f %%)",
109 nbad,ntotal,100.0*nbad/ntotal) << endl;
d565d56c 110
7190ece1 111 if ( statusOnly ) return statusMaker.StatusStore();
d565d56c 112
7190ece1 113 const Bool_t deferredInitialization = kFALSE;
d565d56c 114
7190ece1 115 AliMUONPadStatusMapMaker statusMapMaker(cd,mask,deferredInitialization);
116
117 return statusMapMaker.StatusMap();
d565d56c 118}