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