]>
Commit | Line | Data |
---|---|---|
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 | 36 | using std::endl; |
37 | using std::cout; | |
ea199e33 | 38 | /// \cond CLASSIMP |
39 | ClassImp(AliMUONCheckItem) | |
40 | /// \endcond | |
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), | |
630711ed | 48 | fMissing(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 | //_____________________________________________________________________________ | |
59 | AliMUONCheckItem::~AliMUONCheckItem() | |
60 | { | |
61 | /// dtor | |
62 | delete fMissing; | |
63 | } | |
64 | ||
65 | //_____________________________________________________________________________ | |
66 | Bool_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 | //_____________________________________________________________________________ | |
91 | void | |
92 | AliMUONCheckItem::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 | //_____________________________________________________________________________ |
127 | TIterator* | |
128 | AliMUONCheckItem::CreateIterator() const | |
129 | { | |
130 | /// Create iterator on this item | |
131 | return fMissing->CreateIterator(); | |
132 | } | |
133 | ||
ea199e33 | 134 | //_____________________________________________________________________________ |
135 | TObject* | |
136 | AliMUONCheckItem::GetItem(Int_t id) const | |
137 | { | |
138 | /// Return item of a given id | |
139 | return fMissing->GetValue(id); | |
140 | } | |
141 | ||
142 | //_____________________________________________________________________________ | |
143 | Bool_t | |
144 | AliMUONCheckItem::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 | //_____________________________________________________________________________ | |
155 | Bool_t | |
156 | AliMUONCheckItem::IsFull() const | |
157 | { | |
158 | /// Whether we have as many sub-items as possible | |
159 | return (fMissing->GetSize() == fMaximum); | |
160 | } | |
161 | ||
162 | //_____________________________________________________________________________ | |
163 | void | |
164 | AliMUONCheckItem::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 | } |