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