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