]>
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 | ||
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 | |
37 | ClassImp(AliMUONCheckItem) | |
38 | /// \endcond | |
39 | ||
40 | //_____________________________________________________________________________ | |
41 | AliMUONCheckItem::AliMUONCheckItem(Int_t id, Int_t maxNumber, const char* name) : | |
42 | TNamed(name,name), | |
43 | fID(id), | |
44 | fDead(-1), | |
45 | fMaximum(maxNumber), | |
46 | fMissing(new AliMpExMap(kTRUE)) | |
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 | //_____________________________________________________________________________ | |
57 | AliMUONCheckItem::~AliMUONCheckItem() | |
58 | { | |
59 | /// dtor | |
60 | delete fMissing; | |
61 | } | |
62 | ||
63 | //_____________________________________________________________________________ | |
64 | Bool_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 | //_____________________________________________________________________________ | |
89 | void | |
90 | AliMUONCheckItem::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 | { | |
112 | AliMUONCheckItemIterator it(*this); | |
113 | AliMUONCheckItem* item; | |
114 | it.First(); | |
115 | Int_t ndead(0); | |
116 | fDead=0; | |
117 | while ( ( item = dynamic_cast<AliMUONCheckItem*>(it.Next()) ) ) | |
118 | { | |
119 | if ( item->IsDead() ) ++ndead; | |
120 | } | |
121 | if ( ndead == fMaximum ) fDead = 1; | |
122 | } | |
123 | } | |
124 | ||
125 | //_____________________________________________________________________________ | |
126 | TObject* | |
127 | AliMUONCheckItem::GetItem(Int_t id) const | |
128 | { | |
129 | /// Return item of a given id | |
130 | return fMissing->GetValue(id); | |
131 | } | |
132 | ||
133 | //_____________________________________________________________________________ | |
134 | Bool_t | |
135 | AliMUONCheckItem::IsDead() const | |
136 | { | |
137 | /// Return (and compute it first if not done already) dead status | |
138 | if ( fDead == -1 ) | |
139 | { | |
140 | ComputeDead(); | |
141 | } | |
142 | return (fDead==1); | |
143 | } | |
144 | ||
145 | //_____________________________________________________________________________ | |
146 | Bool_t | |
147 | AliMUONCheckItem::IsFull() const | |
148 | { | |
149 | /// Whether we have as many sub-items as possible | |
150 | return (fMissing->GetSize() == fMaximum); | |
151 | } | |
152 | ||
153 | //_____________________________________________________________________________ | |
154 | void | |
155 | AliMUONCheckItem::Print(Option_t* opt) const | |
156 | { | |
157 | /// output to screen | |
158 | cout << Form("<AliMUONCheckItem> %s ID %d has %d items over %d max. Dead %d", | |
159 | GetName(),fID,fMissing->GetSize(),fMaximum,IsDead()) << endl; | |
160 | TString sopt(opt); | |
161 | sopt.ToLower(); | |
162 | if (sopt.Contains("all") ) | |
163 | { | |
164 | TObject* object(0x0); | |
165 | ||
166 | AliMUONCheckItemIterator it(*this); | |
167 | ||
168 | it.First(); | |
169 | ||
170 | while ( ( object = it.Next() ) ) | |
171 | { | |
172 | object->Print(opt); | |
173 | } | |
174 | } | |
175 | } |