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