]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONStatusMap.C
Replacement of AliMpIntPair object with algoritmic
[u/mrichter/AliRoot.git] / MUON / MUONStatusMap.C
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
18 /// \ingroup macros
19 /// \file MUONStatusMap.C
20 /// \brief Macro to check/test pad status and pad status map makers
21 ///
22 /// \author Laurent Aphecetche
23
24 #if !defined(__CINT__) || defined(__MAKECINT__)
25 #include "AliCDBManager.h"
26 #include "AliMUONCalibrationData.h"
27 #include "AliMUONPadStatusMaker.h"
28 #include "AliMUONPadStatusMapMaker.h"
29 #include "AliMUONVCalibParam.h"
30 #include "AliMUONVStore.h"
31 #include "AliMpCDB.h"
32 #include "AliMpConstants.h"
33 #include "AliMpDDLStore.h"
34 #include "AliMpDetElement.h"
35 #include "AliMpManuIterator.h"
36 #include "Riostream.h"
37 #endif
38
39 void FindBad(AliMUONPadStatusMaker& statusMaker, Int_t mask, Int_t& nBadPads, Int_t& nPads)
40 {
41   AliMpManuIterator it;
42   
43   nBadPads = nPads = 0;
44   
45   Int_t detElemId;
46   Int_t manuId;
47   
48   while ( it.Next(detElemId,manuId) )
49   {
50     Bool_t bad(kFALSE);
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 )
58     {
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       }
71     }
72     
73     if (bad)
74     {
75       cout << Form("DE %4d ManuId %4d %2d bad pads over %2d pads",
76                    detElemId,manuId,nb,n) << endl;
77     }
78   }
79 }
80
81 AliMUONVStore* MUONStatusMap(const TString& cdbStorage = "local://$ALICE_ROOT/OCDB",
82                              Int_t runNumber=0, Bool_t statusOnly=kFALSE, 
83                              Int_t mask=0x8080)
84 {  
85   AliCDBManager::Instance()->SetDefaultStorage(cdbStorage.Data());
86   AliCDBManager::Instance()->SetRun(runNumber);
87
88   AliMpCDB::LoadDDLStore();
89   
90   AliMUONCalibrationData cd(runNumber);
91   
92   AliMUONPadStatusMaker statusMaker(cd);
93   
94 //  statusMaker.SetPedMeanLimits(50,200);
95 //  statusMaker.SetPedSigmaLimits(0.5,2);
96   
97   Int_t nbad;
98   Int_t ntotal;
99   
100   FindBad(statusMaker,mask,nbad,ntotal);
101
102   if (ntotal<=0) 
103   {
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;
110   
111   if ( statusOnly ) return statusMaker.StatusStore();
112   
113   const Bool_t deferredInitialization = kFALSE;
114   
115   AliMUONPadStatusMapMaker statusMapMaker(cd,mask,deferredInitialization);
116     
117   return statusMapMaker.StatusMap();
118 }