]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONCheckItem.cxx
Adding HV currents to the MUON/Calib/OCDB object
[u/mrichter/AliRoot.git] / MUON / AliMUONCheckItem.cxx
CommitLineData
ea199e33 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#include "AliMUONCheckItem.h"
19
20#include "AliLog.h"
21#include "AliMpExMap.h"
24dbd5dd 22#include "AliMpExMapIterator.h"
ea199e33 23#include "Riostream.h"
ea199e33 24
3d1463c8 25//-----------------------------------------------------------------------------
ea199e33 26/// \class AliMUONCheckItem
27///
28/// A structure used to gather information at different levels (ch,manu,de,chamber)
29///
30/// Used by AliMUON2DStoreValidator to present results in a concise way
31///
32///
33/// \author Laurent Aphecetche
3d1463c8 34//-----------------------------------------------------------------------------
ea199e33 35
b80faac0 36using std::endl;
37using std::cout;
ea199e33 38/// \cond CLASSIMP
39ClassImp(AliMUONCheckItem)
40/// \endcond
41
42//_____________________________________________________________________________
43AliMUONCheckItem::AliMUONCheckItem(Int_t id, Int_t maxNumber, const char* name) :
44TNamed(name,name),
45fID(id),
46fDead(-1),
47fMaximum(maxNumber),
630711ed 48fMissing(new AliMpExMap)
ea199e33 49{
50 /// ctor. id is the number of that item, maxNumber is the maximum number
51 /// of sub-item it can contains, and name is a label, e.g. de, chamber, manu.
52 /// Note that name="manu" has a special influence on the IsDead() method.
53
54 fMissing->SetSize(fMaximum);
55 AliDebug(1,Form("ID %d maxNumber %d name %s",id,maxNumber,name));
56}
57
58//_____________________________________________________________________________
59AliMUONCheckItem::~AliMUONCheckItem()
60{
61 /// dtor
62 delete fMissing;
63}
64
65//_____________________________________________________________________________
66Bool_t AliMUONCheckItem::AddItem(Int_t id, TObject* item)
67{
68 /// Add an item, if possible.
69
70 if ( IsFull() )
71 {
72 AliError("I'm already full!");
73 return kFALSE;
74 }
75
76 TObject* test = GetItem(id);
77 if (test)
78 {
79 AliError(Form("id %d is already there !",id));
80 return kFALSE;
81 }
82 else
83 {
84 fMissing->Add(id,item);
85 fDead=-1;
86 }
87 return kTRUE;
88}
89
90//_____________________________________________________________________________
91void
92AliMUONCheckItem::ComputeDead() const
93{
94 /// Decide whether this item is completely dead, which is determined by
95 /// the fact that all its sub-items are dead, or for name="manu", by
96 /// the fact that all channels are missing, i.e. IsFull()==kTRUE
97
98 TString name(GetName());
99 name.ToLower();
100
101 if ( name.Contains("manu") )
102 {
103 if ( IsFull() )
104 {
105 fDead=1;
106 }
107 else
108 {
109 fDead=0;
110 }
111 }
112 else
113 {
24dbd5dd 114 TIter next(CreateIterator());
ea199e33 115 AliMUONCheckItem* item;
ea199e33 116 Int_t ndead(0);
117 fDead=0;
24dbd5dd 118 while ( ( item = dynamic_cast<AliMUONCheckItem*>(next()) ) )
ea199e33 119 {
120 if ( item->IsDead() ) ++ndead;
121 }
122 if ( ndead == fMaximum ) fDead = 1;
123 }
124}
125
24dbd5dd 126//_____________________________________________________________________________
127TIterator*
128AliMUONCheckItem::CreateIterator() const
129{
130 /// Create iterator on this item
131 return fMissing->CreateIterator();
132}
133
ea199e33 134//_____________________________________________________________________________
135TObject*
136AliMUONCheckItem::GetItem(Int_t id) const
137{
138 /// Return item of a given id
139 return fMissing->GetValue(id);
140}
141
142//_____________________________________________________________________________
143Bool_t
144AliMUONCheckItem::IsDead() const
145{
146 /// Return (and compute it first if not done already) dead status
147 if ( fDead == -1 )
148 {
149 ComputeDead();
150 }
151 return (fDead==1);
152}
153
154//_____________________________________________________________________________
155Bool_t
156AliMUONCheckItem::IsFull() const
157{
158 /// Whether we have as many sub-items as possible
159 return (fMissing->GetSize() == fMaximum);
160}
161
162//_____________________________________________________________________________
163void
164AliMUONCheckItem::Print(Option_t* opt) const
165{
166 /// output to screen
167 cout << Form("<AliMUONCheckItem> %s ID %d has %d items over %d max. Dead %d",
168 GetName(),fID,fMissing->GetSize(),fMaximum,IsDead()) << endl;
169 TString sopt(opt);
170 sopt.ToLower();
171 if (sopt.Contains("all") )
172 {
173 TObject* object(0x0);
174
24dbd5dd 175 TIter next(CreateIterator());
ea199e33 176
24dbd5dd 177 while ( ( object = next() ) )
ea199e33 178 {
179 object->Print(opt);
180 }
181 }
182}