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