]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUON2DStoreValidator.cxx
Introduced new DE names unique to each det element;
[u/mrichter/AliRoot.git] / MUON / AliMUON2DStoreValidator.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 "AliMUON2DStoreValidator.h"
19
20#include "AliLog.h"
21#include "AliMUONCalibParam1I.h"
22#include "AliMpIntPair.h"
23#include "AliMpManuList.h"
24#include "AliMUONV2DStore.h"
25#include "TList.h"
26#include "TObjArray.h"
27#include "AliMUONCheckItem.h"
28#include "AliMUONCheckItemIterator.h"
29#include "AliMpDEManager.h"
30#include "TObjString.h"
31#include "AliMUONConstants.h"
32#include "Riostream.h"
33
34/// \class AliMUON2DStoreValidator
35///
36/// Determine which channels, manus, DEs, stations are missing
37/// from a 2DStore. This is mainly to be used during (shuttle) preprocessing
38/// to insure that what we'll put in the CDB is as complete as possible,
39/// and to detect possible problem.
40///
41/// We made an effort to present the result of the validation in the most
42/// concise way (i.e. if all channels of a DE are missing, we do not list
43/// them, we just write "DE dead" ;-) )
44///
45/// The list of missing things is kept in a structure of objects defined as :
46///
47/// fMissing = TObjArray[0..N tracking chambers]
48/// fMissing[iChamber] = AliMUONCheckItem which contains n AliMUONCheckItem,
49/// where n is the number of DE for that chamber
50/// fMissing[iChamber]->GetItem(de) = AliMUONCheckItem which contains m
51/// AliMUONCheckItem where m is the number of Manu for that DE
52/// fMissing[iChamber]->GetItem(de)->GetItem(manu) = AliMUONCheckItem which
53/// contains k TObjString = Form("%d",manuChannel)
54///
55/// \author Laurent Aphecetche
56
57/// \cond CLASSIMP
58ClassImp(AliMUON2DStoreValidator)
59/// \endcond
60
61//_____________________________________________________________________________
62AliMUON2DStoreValidator::AliMUON2DStoreValidator()
63: TObject(),
64 fManuList(0x0),
65 fChambers(0x0)
66{
67 /// ctor
68}
69
70//_____________________________________________________________________________
71AliMUON2DStoreValidator::~AliMUON2DStoreValidator()
72{
73 /// dtor
74 delete fManuList;
75 delete fChambers;
76}
77
78//_____________________________________________________________________________
79AliMUONCheckItem*
80AliMUON2DStoreValidator::GetChamber(Int_t chamberID)
81{
82 /// Return (and create if not present) the given chamber
83 /// chamberID in 0..NCh()
84
85 if ( chamberID < 0 || chamberID >= AliMUONConstants::NCh() )
86 {
87 AliFatal(Form("Invalid chamber number %d",chamberID));
88 return 0x0;
89 }
90
91 if (!fChambers)
92 {
93 fChambers = new TObjArray(AliMUONConstants::NCh());
94 }
95
96 AliMUONCheckItem* chamber =
97 static_cast<AliMUONCheckItem*>(fChambers->At(chamberID));
98
99 if (!chamber)
100 {
101 chamber = new AliMUONCheckItem(chamberID,
102 AliMpDEManager::GetNofDEInChamber(chamberID),
103 "Chamber");
104 fChambers->AddAt(chamber,chamberID);
105 }
106 return chamber;
107}
108
109//_____________________________________________________________________________
110AliMUONCheckItem*
111AliMUON2DStoreValidator::GetDE(Int_t detElemId)
112{
113 /// Return (and create if not present) a given detection element
114
115 Int_t chamberID = AliMpDEManager::GetChamberId(detElemId);
116 AliMUONCheckItem* chamber = GetChamber(chamberID);
117 AliMUONCheckItem* de =
118 static_cast<AliMUONCheckItem*>(chamber->GetItem(detElemId));
119 if (!de)
120 {
121 AliDebug(3,Form("Did not find DE %4d into chamber %d, will create it",
122 detElemId,chamberID));
123 de = new AliMUONCheckItem(detElemId,
124 AliMpManuList::NumberOfManus(detElemId),
125 "Detection Element");
126 Bool_t ok = chamber->AddItem(detElemId,de);
127 if (!ok)
128 {
129 AliError(Form("Could not add DE %4d into chamber %2d",detElemId,chamberID));
130 }
131 }
132 return de;
133}
134
135//_____________________________________________________________________________
136AliMUONCheckItem*
137AliMUON2DStoreValidator::GetManu(Int_t detElemId, Int_t manuId)
138{
139 /// Return (and create) a given manu
140
141 AliMUONCheckItem* de = GetDE(detElemId);
142 AliMUONCheckItem* manu = static_cast<AliMUONCheckItem*>(de->GetItem(manuId));
143 if (!manu)
144 {
145 manu = new AliMUONCheckItem(manuId,AliMpManuList::NumberOfChannels(detElemId,manuId),"Manu");
146 Bool_t ok = de->AddItem(manuId,manu);
147 if (!ok)
148 {
149 AliError(Form("Could not add manu %4d into DE %4d",manuId,detElemId));
150 }
151
152 }
153 return manu;
154}
155
156//_____________________________________________________________________________
157void
158AliMUON2DStoreValidator::AddMissingChannel(Int_t detElemId,
159 Int_t manuId, Int_t manuChannel)
160{
161 /// Add one missing channel to the list of missing things
162
163 AliDebug(3,Form("DE %4d Manu %4d Channel %2d is missing",
164 detElemId,manuId,manuChannel));
165
166 AliMUONCheckItem* manu = GetManu(detElemId,manuId);
167 Bool_t ok = manu->AddItem(manuChannel,new TObjString(Form("%2d",manuChannel)));
168 if (!ok)
169 {
170 AliError(Form("Could not add channel %2d to manuId %4d in DE %4d",
171 manuChannel,manuId,detElemId));
172 }
173}
174
175//_____________________________________________________________________________
176void
177AliMUON2DStoreValidator::AddMissingManu(Int_t detElemId, Int_t manuId)
178{
179 /// Add one missing manu to the list of missing things
180
181 AliDebug(3,Form("DE %4d Manu %4d is completely missing",
182 detElemId,manuId));
183
184 Int_t n(AliMpManuList::NumberOfChannels(detElemId,manuId));
185
186 for ( Int_t i = 0; i < n; ++i )
187 {
188 AddMissingChannel(detElemId,manuId,i);
189 }
190}
191
192//_____________________________________________________________________________
193void
194AliMUON2DStoreValidator::ReportManu(AliMUONCheckItem& manu)
195{
196 /// Report list of missing channels from this manu
197
198 TObjString* channel(0x0);
199 AliMUONCheckItemIterator it(manu);
200
201 it.First();
202
203 while ( ( channel = static_cast<TObjString*>(it.Next()) ) )
204 {
205 cout << Form("\t\t\tChannel %s is missing",channel->GetString().Data()) << endl;
206 }
207
208}
209
210//_____________________________________________________________________________
211void
212AliMUON2DStoreValidator::ReportDE(AliMUONCheckItem& de)
213{
214 /// Report list of missing manus from this de
215 AliMUONCheckItem* manu(0x0);
216 AliMUONCheckItemIterator it(de);
217
218 cout << Form("\tDE %4d",de.GetID()) << endl;
219
220 it.First();
221
222 while ( ( manu = static_cast<AliMUONCheckItem*>(it.Next()) ) )
223 {
224 if ( manu->IsDead() )
225 {
226 cout << Form("\t\tManu %4d is missing",manu->GetID()) << endl;
227 }
228 else
229 {
230 ReportManu(*manu);
231 }
232 }
233}
234
235//_____________________________________________________________________________
236void
237AliMUON2DStoreValidator::ReportChamber(AliMUONCheckItem& chamber)
238{
239 /// Report list of missing de from this chamber
240
241 AliMUONCheckItem* de(0x0);
242 AliMUONCheckItemIterator it(chamber);
243
244 it.First();
245
246 while ( ( de = static_cast<AliMUONCheckItem*>(it.Next()) ) )
247 {
248 if ( de->IsDead() )
249 {
250 cout << Form("\tDE %4d is missing",de->GetID()) << endl;
251 }
252 else
253 {
254 ReportDE(*de);
255 }
256 }
257}
258
259//_____________________________________________________________________________
260void
261AliMUON2DStoreValidator::Report(const TObjArray& chambers)
262{
263 /// Reports what is missing, trying to be as concise as possible.
264
265 for ( Int_t iChamber = 0; iChamber <= chambers.GetLast(); ++iChamber )
266 {
267 AliMUONCheckItem* chamber = static_cast<AliMUONCheckItem*>(chambers.At(iChamber));
268 if ( chamber )
269 {
270 if ( chamber->IsDead() )
271 {
272 cout << Form("Chamber %2d is missing",iChamber) << endl;
273 }
274 else
275 {
276 ReportChamber(*chamber);
277 }
278 }
279 }
280}
281
282//_____________________________________________________________________________
283TObjArray*
284AliMUON2DStoreValidator::Validate(const AliMUONV2DStore& store,
285 Float_t invalidFloatValue)
286{
287 /// Validate the store.
288 /// The invalidFloatValue is used to decide if a store content value
289 /// is valid or not.
290
291 delete fChambers;
292 fChambers = 0x0;
293
294 if (!fManuList) fManuList = AliMpManuList::ManuList();
295
296 // Now checks if some full manus are missing
297 TIter next(fManuList);
298 AliMpIntPair* p;
299
300 while ( ( p = (AliMpIntPair*)next() ) )
301 {
302 Int_t detElemId = p->GetFirst();
303 Int_t manuId = p->GetSecond();
304 AliMUONVCalibParam* test =
305 static_cast<AliMUONVCalibParam*>(store.Get(detElemId,manuId));
306 if (!test)
307 {
308 // completely missing manu
309 AddMissingManu(detElemId,manuId);
310 }
311 else
312 {
313 // manu is there, check all its channels
314 for ( Int_t manuChannel = 0 ; manuChannel < test->Size(); ++manuChannel )
315 {
316 if ( AliMpManuList::DoesChannelExist(detElemId,manuId,manuChannel) &&
317 ( test->ValueAsFloat(manuChannel,0) == invalidFloatValue ||
318 test->ValueAsFloat(manuChannel,1) == invalidFloatValue ) )
319 {
320 AddMissingChannel(detElemId,manuId,manuChannel);
321 }
322 }
323 }
324 }
325 return fChambers;
326}
327
328