AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONCheckItem.cxx
Go to the documentation of this file.
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"
22 #include "AliMpExMapIterator.h"
23 #include "Riostream.h"
24 
25 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
35 
36 using std::endl;
37 using std::cout;
41 
42 //_____________________________________________________________________________
43 AliMUONCheckItem::AliMUONCheckItem(Int_t id, Int_t maxNumber, const char* name) :
44 TNamed(name,name),
45 fID(id),
46 fDead(-1),
47 fMaximum(maxNumber),
48 fMissing(new AliMpExMap)
49 {
53 
54  fMissing->SetSize(fMaximum);
55  AliDebug(1,Form("ID %d maxNumber %d name %s",id,maxNumber,name));
56 }
57 
58 //_____________________________________________________________________________
60 {
62  delete fMissing;
63 }
64 
65 //_____________________________________________________________________________
66 Bool_t AliMUONCheckItem::AddItem(Int_t id, TObject* item)
67 {
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 //_____________________________________________________________________________
91 void
93 {
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  {
114  TIter next(CreateIterator());
115  AliMUONCheckItem* item;
116  Int_t ndead(0);
117  fDead=0;
118  while ( ( item = dynamic_cast<AliMUONCheckItem*>(next()) ) )
119  {
120  if ( item->IsDead() ) ++ndead;
121  }
122  if ( ndead == fMaximum ) fDead = 1;
123  }
124 }
125 
126 //_____________________________________________________________________________
127 TIterator*
129 {
131  return fMissing->CreateIterator();
132 }
133 
134 //_____________________________________________________________________________
135 TObject*
137 {
139  return fMissing->GetValue(id);
140 }
141 
142 //_____________________________________________________________________________
143 Bool_t
145 {
147  if ( fDead == -1 )
148  {
149  ComputeDead();
150  }
151  return (fDead==1);
152 }
153 
154 //_____________________________________________________________________________
155 Bool_t
157 {
159  return (fMissing->GetSize() == fMaximum);
160 }
161 
162 //_____________________________________________________________________________
163 void
164 AliMUONCheckItem::Print(Option_t* opt) const
165 {
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 
175  TIter next(CreateIterator());
176 
177  while ( ( object = next() ) )
178  {
179  object->Print(opt);
180  }
181  }
182 }
TObject * GetItem(Int_t id) const
void ComputeDead() const
void Print(Option_t *opt="") const
Int_t fMaximum
! maximum number of sub-items possible within this item
TIterator * CreateIterator() const
Bool_t IsFull() const
Bool_t AddItem(Int_t id, TObject *item)
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Int_t GetSize() const
Definition: AliMpExMap.cxx:340
Int_t fID
! identifier of this item
AliMpExMap * fMissing
! pointers to the sub-items
TObject * GetValue(Int_t keyFirst, Int_t keySecond) const
Definition: AliMpExMap.cxx:365
void Add(Int_t keyFirst, Int_t keySecond, TObject *object)
Definition: AliMpExMap.cxx:292
virtual ~AliMUONCheckItem()
A structure used to gather information at different levels (ch,manu,de,chamber)
Bool_t IsDead() const
Helper class making Root persistent TExMap.
Definition: AliMpExMap.h:28
AliMpExMapIterator * CreateIterator() const
Definition: AliMpExMap.cxx:357
Int_t fDead
! whether this object is completely dead